package com.hmall.user.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hmall.user.pojo.Address;
import com.hmall.user.pojo.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author 29143
 */
public interface UserMapper extends BaseMapper<Address> {


    /**
     * 根据用户id查询地址列表
     * 返回list集合
     * @param userId
     * @return
     */
    @Select("select * from tb_address where user_id = #{userId}")
    public List<Address> findAddressListById(Long userId);

    @Select("select * from tb_user where id = #{userId}")
    User findUserById(Long userId);

    @Update("update tb_user set balance=(balance-#{money}) where id = #{userId}")
    Integer payMoney(@Param("userId") Long userId, @Param("money") Long money);



}
